package com.hiultra.archive.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hiultra.common.annotation.Log;
import com.hiultra.common.core.controller.BaseController;
import com.hiultra.common.core.domain.AjaxResult;
import com.hiultra.common.enums.BusinessType;
import com.hiultra.archive.domain.ArchiveStocktakingBox;
import com.hiultra.archive.service.IArchiveStocktakingBoxService;
import com.hiultra.common.utils.poi.ExcelUtil;
import com.hiultra.common.core.page.TableDataInfo;

/**
 * 盒盘点上送结果数据Controller
 *
 * @author paidaxing
 * @date 2024-07-31
 */
@RestController
@RequestMapping("/archive/ArchiveStocktakingBox")
public class ArchiveStocktakingBoxController extends BaseController
{
    @Autowired
    private IArchiveStocktakingBoxService archiveStocktakingBoxService;

    /**
     * 查询盒盘点上送结果数据列表
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveStocktakingBox:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArchiveStocktakingBox archiveStocktakingBox)
    {
        startPage();
        List<ArchiveStocktakingBox> list = archiveStocktakingBoxService.selectArchiveStocktakingBoxList(archiveStocktakingBox);
        return getDataTable(list);
    }

    /**
     * 导出盒盘点上送结果数据列表
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveStocktakingBox:export')")
    @Log(title = "盒盘点上送结果数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArchiveStocktakingBox archiveStocktakingBox)
    {
        List<ArchiveStocktakingBox> list = archiveStocktakingBoxService.selectArchiveStocktakingBoxList(archiveStocktakingBox);
        ExcelUtil<ArchiveStocktakingBox> util = new ExcelUtil<ArchiveStocktakingBox>(ArchiveStocktakingBox.class);
        util.exportExcel(response, list, "盒盘点上送结果数据数据");
    }

    /**
     * 获取盒盘点上送结果数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveStocktakingBox:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(archiveStocktakingBoxService.selectArchiveStocktakingBoxById(id));
    }

    /**
     * 新增盒盘点上送结果数据
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveStocktakingBox:add')")
    @Log(title = "盒盘点上送结果数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArchiveStocktakingBox archiveStocktakingBox)
    {
        return toAjax(archiveStocktakingBoxService.insertArchiveStocktakingBox(archiveStocktakingBox));
    }

    /**
     * 后台用接口——新增盒盘点上送结果数据
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveStocktakingBox:addStocktakingBox')")
    @Log(title = "盒盘点上送结果数据", businessType = BusinessType.INSERT)
    @PostMapping("/addStocktakingBox")
    public AjaxResult addStocktakingBox(@RequestBody ArchiveStocktakingBox archiveStocktakingBox)
    {
        return archiveStocktakingBoxService.insertStocktakingBox(archiveStocktakingBox);
    }

    /**
     * 修改盒盘点上送结果数据
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveStocktakingBox:edit')")
    @Log(title = "盒盘点上送结果数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArchiveStocktakingBox archiveStocktakingBox)
    {
        return toAjax(archiveStocktakingBoxService.updateArchiveStocktakingBox(archiveStocktakingBox));
    }

    /**
     * 修改盒盘点结果数据
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveStocktakingBox:editStocktakingBox')")
    @Log(title = "修改盒盘点结果数据", businessType = BusinessType.UPDATE)
    @PostMapping("/editStocktakingBox")
    public AjaxResult editStocktakingBox(@RequestBody ArchiveStocktakingBox archiveStocktakingBox)
    {
        return toAjax(archiveStocktakingBoxService.editStocktakingBox(archiveStocktakingBox));
    }

    /**
     * 删除盒盘点上送结果数据
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveStocktakingBox:remove')")
    @Log(title = "盒盘点上送结果数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(archiveStocktakingBoxService.deleteArchiveStocktakingBoxByIds(ids));
    }
    /**
     * 根据任务id获取档案盒列表详细信息 Mary
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveStocktakingBox:query')")
    @GetMapping(value = "/selectBoxByTaskId/{taskId}")
    public AjaxResult selectBoxByTaskId(@PathVariable("taskId") String taskId)
    {
        return AjaxResult.success(archiveStocktakingBoxService.selectBoxByTaskId(taskId));
    }
}
